#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QNetworkInterface>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();
    foreach (QNetworkInterface netInterface, list) {
        QList<QNetworkAddressEntry> entryList = netInterface.addressEntries();
        foreach(QNetworkAddressEntry entry, entryList) {  // 遍历每一个IP地址
            qDebug() << "********************";
            qDebug() << "IP Address:" << entry.ip().toString();  // IP地址
            qDebug() << "Netmask:" << entry.netmask().toString();  // 子网掩码
            qDebug() << "Broadcast:" << entry.broadcast().toString();  // 广播地址
            qDebug() << "Prefix Length:" << entry.prefixLength();  // 前缀长度
        }
    }
}


MainWindow::~MainWindow()
{
    delete ui;
}
